package cn.com.miao.lynx.common.core.syntactic

/**
 * Operator
 * 扩展操作符
 * @title: Operator
 * @description:
 * @author: dengmiao
 * @create: 2019-12-31 13:32
 **/
inline fun<T, E> Iterable<T>.convert(action: (T) -> E): MutableList<E> {
    val list: MutableList<E> = mutableListOf()
    for (item in this) {
        list.add(action(item))
    }
    return list
}

fun main() {
    val list: List<Int> = listOf(1, 2, 3, 4, 5)
    list.convert { it + 1 }.forEach{ it1 -> println(it1) }
}
